﻿using MES.Core;
using MES.Service.Generate;
using MES.Service.Generate.Dto;
using Microsoft.AspNetCore.Mvc;

namespace MES.API.Controllers
{
    /// <summary>
    /// 代码管理
    /// </summary>
    [Route("api/[controller]/[Action]")]
    [ApiVersion("1.0", Deprecated = false)]
    [ApiController]
    public class GenerateController : ControllerBase
    {
        private readonly IGenerateService generateService;

        public GenerateController(IGenerateService generateService)
        {
            this.generateService = generateService;
        }
        /// <summary>
        /// 生成实体
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<OperateResult> GenerateModel([FromBody] GenerateModelInput input)
        {
            return await generateService.GenerateModel(input);
        }

        /// <summary>
        /// 重新加载程序集
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<OperateResult> HotLoading()
        {
            return await generateService.HotLoading();
        }


        /// <summary>
        /// 生成Controller代码 (简单的增删改查)
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<OperateResult> GenerateCode([FromBody] GenerateCodeInput input)
        {
            return await generateService.GenerateCode(input);
        }


    }
}
